import { EntitySchema } from '@mikro-orm/core';

export class LeOrder {
  id!: string;
  orderSn!: string;
  UID!: string;
  totalAmount!: string;
  payAmount!: string;
  goodsAmount!: string;
  goodsReduced!: string;
  freightAmount!: string;
  freightReduced!: string;
  couponReduced!: string;
  status: number = 100;
  cancelTime?: string;
  sendTime?: string;
  receivedTime?: string;
  finishTime?: string;
  afterSales: boolean = false;
  source!: string;
  payNumber?: string;
  payType?: string;
  payTime?: string;
  note?: string;
  merchantId!: string;
  AppID!: string;
  createdTime!: string;
  updatedTime?: string;
  deletedTime?: string;
  isDeleted: boolean = false;
  isEvaluate: boolean = false;
  evaluateTime?: string;
  isRecycle?: boolean = false;
  scoreAmount!: string;
  totalScore!: string;
  type?: string;
  isPromoter?: boolean = false;
  promoterReduced!: string;
}

export const LeOrderSchema = new EntitySchema({
  class: LeOrder,
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    orderSn: { type: 'string', length: 50, index: '订单编号' },
    UID: { type: 'string', fieldName: 'UID', columnType: 'bigint', index: '用户id' },
    totalAmount: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    payAmount: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    goodsAmount: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    goodsReduced: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    freightAmount: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    freightReduced: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    couponReduced: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    status: { type: 'number', columnType: 'smallint', default: 100 },
    cancelTime: { type: 'string', columnType: 'bigint', nullable: true, defaultRaw: `0` },
    sendTime: { type: 'string', columnType: 'bigint', nullable: true },
    receivedTime: { type: 'string', columnType: 'bigint', nullable: true },
    finishTime: { type: 'string', columnType: 'bigint', nullable: true },
    afterSales: { type: 'boolean', default: false },
    source: { type: 'string', length: 50 },
    payNumber: { type: 'string', length: 50, nullable: true },
    payType: { type: 'string', length: 20, nullable: true },
    payTime: { type: 'string', columnType: 'bigint', nullable: true },
    note: { type: 'string', length: 255, nullable: true },
    merchantId: { type: 'string', columnType: 'bigint', index: '商户id' },
    AppID: { type: 'string', fieldName: 'AppID', length: 50, index: '应用id' },
    createdTime: { type: 'string', columnType: 'bigint' },
    updatedTime: { type: 'string', columnType: 'bigint', nullable: true },
    deletedTime: { type: 'string', columnType: 'bigint', nullable: true },
    isDeleted: { type: 'boolean', default: false },
    isEvaluate: { type: 'boolean', default: false },
    evaluateTime: { type: 'string', columnType: 'bigint', nullable: true },
    isRecycle: { type: 'boolean', nullable: true, default: false },
    scoreAmount: { type: 'string', columnType: 'bigint', defaultRaw: `0` },
    totalScore: { type: 'string', columnType: 'bigint', defaultRaw: `0` },
    type: { type: 'string', length: 255, nullable: true },
    isPromoter: { type: 'boolean', nullable: true, default: false },
    promoterReduced: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
  },
});
